<template>
  <div class="wrap">
    <div class="wrap-l">
      <div
        class="tree-box"
        :style="{ height: show_control ? height1 : height2 }"
      >
        <div class="title">设备列表</div>
        <Tree />
      </div>
      <div
        class="control-box"
        :style="{ height: show_control ? height3 : height4 }"
        v-permissions="{
          url: ['device/ptzcontrol'],
          hasDisplay: true,
        }"
      >
        <div class="con" v-if="show_control">
          <div class="title">云控制台</div>
          <Control />
        </div>
      </div>
    </div>
    <div class="wrap-r">
      <VideoWrap />
    </div>
  </div>
</template>

<script>
import Tree from "./coms/Tree";
import Control from "./coms/Control";
import VideoWrap from "./coms/VideoWrap";
import bus from "@/utils/bus";
export default {
  name: "",
  components: {
    Tree,
    Control,
    VideoWrap,
  },
  props: {},
  data() {
    return {
      show_control: false, //根据这个字段，控制台的显示隐藏
      height1: "60%",
      height2: "100%",
      height3: "40%",
      height4: "0",
    };
  },
  computed: {},
  created() {},
  mounted() {
    var that = this;
    //获取到从tree传递的数据,改变控制台的显示隐藏
    bus.$on("changeVideo", (_new) => {
     // console.log(_new);
      that.show_control = true;
      if (_new.reg_type == 7) {
        that.show_control = true;
      } else {
        that.show_control = false;
      }
    });

    //获取到从videoWrap传递的数据,改变控制台的显示隐藏
    bus.$on("videoSelectedIndex", (index, _videoSrcArr) => {
      that.show_control = true;
        if (
          _videoSrcArr[index].reg_type == 7 &&
          _videoSrcArr[index].status != false
        ) {
          that.show_control = true;
        } else {
          that.show_control = false;
        }
    });

    //在video中,点击单个停止后，来改变控制台的显示隐藏
    bus.$on("hideControl", (item) => {
      that.show_control = false;
    });
  },
  methods: {},
  watch: {},
};
</script>
<style scoped>
.wrap {
  /* height: calc(100vh - 100px); */
  height: calc(100vh - 60px);
  margin: -20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #031229;
}
.wrap-l {
  width: 20%;
  height: 100%;
  box-shadow: 1px 0px 10px #446ab6;
  display: flex;
  flex-flow: column;
}
.wrap-r {
  flex: 1;
  height: 100%;
  margin-left: 20px;
  /* box-shadow: 0 10px 10px #d6d6d6; */
}

.wrap-l .tree-box {
  width: 100%;
  flex: 1;
  border-radius: 10px;
  border-radius: 10px;
  overflow: hidden;
}
.wrap-l .control-box {
  width: 100%;
  border-radius: 10px;
}
.con {
  width: 100%;
  height: 100%;
}
.wrap-l .title {
  width: 100%;
  height: 40px;
  line-height: 40px;
  padding-left: 15px;
  background: #193c7e;
  border-radius: 10px 10px 0 0;
  color: #fff;
  font-size: 14px;
}
</style>
